<!DOCTYPE html>
<!--[if IE 8]><html class="no-js lt-ie9" lang="en" > <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en" > <!--<![endif]-->
<head>
  <meta charset="utf-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta name="description" content="None">
  
  
  <link rel="shortcut icon" href="img/favicon.ico">
  <title>LINSMapping_v1.0</title>
  <link rel="stylesheet" href="https://fonts.googleapis.com/css?family=Lato:400,700|Roboto+Slab:400,700|Inconsolata:400,700" />

  <link rel="stylesheet" href="css/theme.css" />
  <link rel="stylesheet" href="css/theme_extra.css" />
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/styles/github.min.css" />
  
  <script>
    // Current page data
    var mkdocs_page_name = "SDK\u4ecb\u7ecd";
    var mkdocs_page_input_path = "index.md";
    var mkdocs_page_url = null;
  </script>
  
  <script src="js/jquery-2.1.1.min.js" defer></script>
  <script src="js/modernizr-2.8.3.min.js" defer></script>
  <script src="https://cdnjs.cloudflare.com/ajax/libs/highlight.js/9.12.0/highlight.min.js"></script>
  <script>hljs.initHighlightingOnLoad();</script> 
  
</head>

<body class="wy-body-for-nav" role="document">

  <div class="wy-grid-for-nav">

    
    <nav data-toggle="wy-nav-shift" class="wy-nav-side stickynav">
    <div class="wy-side-scroll">
      <div class="wy-side-nav-search">
        <a href="./index.html" class="icon icon-home"> LINSMapping_v1.0</a>
        <div role="search">
  <form id ="rtd-search-form" class="wy-form" action="./search.html" method="get">
    <input type="text" name="q" placeholder="Search docs" title="Type search term here" />
  </form>
</div>
      </div>

      <div class="wy-menu wy-menu-vertical" data-spy="affix" role="navigation" aria-label="main navigation">
                <ul class="current">
                    <li class="toctree-l1 current"><a class="reference internal current" href="./index.html">SDK介绍</a>
    <ul class="current">
    <li class="toctree-l2"><a class="reference internal" href="#sdk">下载与安装SDK</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#_1">目录结构</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#_2">依赖库</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#_3">支持的平台</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#_4">参数配置</a>
    </li>
    <li class="toctree-l2"><a class="reference internal" href="#_5">使用例程</a>
        <ul>
    <li class="toctree-l3"><a class="reference internal" href="#_6">自带例子说明</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#_7">例程文件简览</a>
    </li>
    <li class="toctree-l3"><a class="reference internal" href="#_8">从零开始构建项目</a>
    </li>
        </ul>
    </li>
    </ul>
                    </li>
                </ul>
                <ul>
                    <li class="toctree-l1"><a class="reference internal" href="about/index.html">接口介绍</a>
                    </li>
                </ul>
      </div>
    </div>
    </nav>

    <section data-toggle="wy-nav-shift" class="wy-nav-content-wrap">

      
      <nav class="wy-nav-top" role="navigation" aria-label="top navigation">
        <i data-toggle="wy-nav-top" class="fa fa-bars"></i>
        <a href="./index.html">LINSMapping_v1.0</a>
      </nav>

      
      <div class="wy-nav-content">
        <div class="rst-content">
          <div role="navigation" aria-label="breadcrumbs navigation">
  <ul class="wy-breadcrumbs">
    <li><a href="./index.html">Docs</a> &raquo;</li>
    
      
    
    <li>SDK介绍</li>
    <li class="wy-breadcrumbs-aside">
      
    </li>
  </ul>
  
  <hr/>
</div>
          <div role="main">
            <div class="section">
              
                <h1 id="linsmapping-c-sdk">LINSMapping C++ SDK 介绍</h1>
<blockquote></blockquote>
<h2 id="sdk">下载与安装SDK</h2>
<blockquote>
<p>解压文件包即可</p>
</blockquote>
<h2 id="_1">目录结构</h2>
<p>lins_mapping 下包含三个文件分别是 lib,include,example 其中include下 mapping 文件夹与 localization 文件夹 为项目提供的接口文件</p>
<table>
<thead>
<tr>
<th align="center">文件名</th>
<th align="center">作用</th>
<th align="center">使用方式</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">lib</td>
<td align="center">用于编译的库文件</td>
<td align="center">SDK本身与其依赖的静态库</td>
</tr>
<tr>
<td align="center">include</td>
<td align="center">包含接口的头文件</td>
<td align="center">SDK本身头文件与其依赖的库头文件</td>
</tr>
<tr>
<td align="center">example</td>
<td align="center">项目例程</td>
<td align="center">直接在使用cmake编译运行的测试文件依赖ros</td>
</tr>
<tr>
<td align="center">config</td>
<td align="center">配置文件</td>
<td align="center">项目依赖的参数配置</td>
</tr>
</tbody>
</table>
<hr />
<ul>
<li>include 下sdk文件(lins)详细介绍</li>
</ul>
<table>
<thead>
<tr>
<th align="center">文件名</th>
<th align="center">类型说明</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">localization</td>
<td align="center">文件夹</td>
<td align="center">包含激光定位功能的头文件</td>
</tr>
<tr>
<td align="center">localization_base.h</td>
<td align="center">抽象基类的头文件</td>
<td align="center">整合了公共接口函数名的抽象类</td>
</tr>
<tr>
<td align="center">fusion_localization_manual_init_mtd.h</td>
<td align="center">对外接口的头文件</td>
<td align="center">手动定位</td>
</tr>
<tr>
<td align="center">fusion_localization_auto_init_mtd.h</td>
<td align="center">对外接口的头文件</td>
<td align="center">自动定位</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th align="center">文件名</th>
<th align="center">类型说明</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">mapping</td>
<td align="center">文件夹</td>
<td align="center">内部包含建图功能的头文件</td>
</tr>
<tr>
<td align="center">mapping_base.h</td>
<td align="center">抽象基类的头文件</td>
<td align="center">整合了公共接口函数名的抽象类</td>
</tr>
<tr>
<td align="center">fusion_mapping_mtd.h</td>
<td align="center">对外接口的头文件</td>
<td align="center">建图</td>
</tr>
<tr>
<td align="center">fusion_mapping_merge_mtd.h</td>
<td align="center">对外接口的头文件</td>
<td align="center">合并建图</td>
</tr>
</tbody>
</table>
<hr />
<table>
<thead>
<tr>
<th align="center">文件名</th>
<th align="center">类型说明</th>
<th align="center">作用</th>
</tr>
</thead>
<tbody>
<tr>
<td align="center">core/common</td>
<td align="center">文件夹</td>
<td align="center">内包含底层数据结构的头文件</td>
</tr>
<tr>
<td align="center">basic_types.h</td>
<td align="center">刚好匹配调用接口的对外数据类型的头文件</td>
<td align="center">对需要使用的数据结构的定义</td>
</tr>
<tr>
<td align="center">lins_point_types.h</td>
<td align="center">底层数据结构的头文件,由basic_types.h包含</td>
<td align="center">底层数据结构</td>
</tr>
<tr>
<td align="center">config.h</td>
<td align="center">配置文件类Config的头文件</td>
<td align="center">用户需要加载配置文件时使用此头文件</td>
</tr>
<tr>
<td align="center">timer.h</td>
<td align="center">定时器的头文件</td>
<td align="center">用户需要使用定时器包含此头文件</td>
</tr>
</tbody>
</table>
<h2 id="_2">依赖库</h2>
<table>
<thead>
<tr>
<th>库名</th>
<th>简介</th>
</tr>
</thead>
<tbody>
<tr>
<td>Eigen</td>
<td>Eigen矩阵运算库</td>
</tr>
<tr>
<td>glog</td>
<td>glog日志库</td>
</tr>
<tr>
<td>yaml-cpp</td>
<td>配置文件</td>
</tr>
<tr>
<td>sophus</td>
<td>李代数库</td>
</tr>
<tr>
<td>ceres</td>
<td></td>
</tr>
</tbody>
</table>
<h2 id="_3">支持的平台</h2>
<p>LINSMapping 开发平台为ubuntu18.04, 编译器为 g++/gcc 7.5 </p>
<h2 id="_4">参数配置</h2>
<p>配置文件在 config 下 , 用户可以根据自己需求更改 配置文件</p>
<p>配置全参数介绍如下</p>
<table>
<thead>
<tr>
<th>参数名</th>
<th>作用</th>
</tr>
</thead>
<tbody>
<tr>
<td>map_output</td>
<td>是否输出rmap</td>
</tr>
<tr>
<td>map_output_folder</td>
<td>rmap输出路径</td>
</tr>
<tr>
<td>lidar_topic</td>
<td>激光雷达3D点云数据Topic</td>
</tr>
<tr>
<td>imu_topic</td>
<td>imu数据Topic</td>
</tr>
<tr>
<td>gps_topic</td>
<td>gps数据Topic</td>
</tr>
<tr>
<td>camera0_topic</td>
<td>相机数据Topic,目前没有使用</td>
</tr>
<tr>
<td>gps_use</td>
<td>是否使用GPS数据</td>
</tr>
<tr>
<td>gps_proj</td>
<td>GPS坐标系定义，ENU表示东北天</td>
</tr>
<tr>
<td>gps_proj_enu_lat</td>
<td>GPS坐标系原点纬度</td>
</tr>
<tr>
<td>gps_proj_enu_lon</td>
<td>GPS坐标系原点经度</td>
</tr>
<tr>
<td>gps_proj_enu_alt</td>
<td>GPS坐标系原点高度</td>
</tr>
<tr>
<td>gps_filter_max_hori_std</td>
<td>滤除精度较差的GPS位置点，水平向标准差阈值</td>
</tr>
<tr>
<td>gps_filter_max_vert_std</td>
<td>同上，垂直向标准差阈值</td>
</tr>
<tr>
<td>gps_filter_max_heading_std</td>
<td>同上，航向角（双天线情况下）标准差阈值</td>
</tr>
<tr>
<td>imu_refine</td>
<td>Imu线速度是否需要乘以当地重力加速度g</td>
</tr>
<tr>
<td>num_camera</td>
<td>相机个数</td>
</tr>
<tr>
<td>img_width</td>
<td>相机图像宽度</td>
</tr>
<tr>
<td>img_height</td>
<td>相机图像高度</td>
</tr>
<tr>
<td>device_B_L_rot_x</td>
<td>激光雷达在本体坐标系（一般x轴朝机器人正前方，z朝正上方）下的位姿，滚转角</td>
</tr>
<tr>
<td>device_B_L_rot_y</td>
<td>同上，俯仰角</td>
</tr>
<tr>
<td>device_B_L_rot_z</td>
<td>同上，偏航角</td>
</tr>
<tr>
<td>device_B_L_offset_x</td>
<td>同上，x方向平移量</td>
</tr>
<tr>
<td>device_B_L_offset_y</td>
<td>同上，y方向平移量</td>
</tr>
<tr>
<td>device_B_L_offset_z</td>
<td>同上，z方向平移量</td>
</tr>
<tr>
<td>extrinsic_rotation_imu</td>
<td>IMU在激光坐标系下的位姿，旋转矩阵</td>
</tr>
<tr>
<td>extrinsic_translation_imu</td>
<td>同上，平移向量</td>
</tr>
<tr>
<td>extrinsic_rotation_gps</td>
<td>GPS在激光坐标系下的位姿，旋转矩阵</td>
</tr>
<tr>
<td>extrinsic_translation_gps</td>
<td>同上，平移向量</td>
</tr>
<tr>
<td>keyframe_translation</td>
<td>每隔多少米标记一个关键帧</td>
</tr>
<tr>
<td>keyframe_rotation</td>
<td>每转多少度标记一个关键帧</td>
</tr>
<tr>
<td>laser_distance_min</td>
<td>3D点云距离滤波，最小距离</td>
</tr>
<tr>
<td>laser_distance_max</td>
<td>3D点云距离滤波，最大距离</td>
</tr>
<tr>
<td>min_plane_dis</td>
<td>进行点到面配准时，最小距离</td>
</tr>
<tr>
<td>min_match_sq_dis</td>
<td>同上，knn搜索时，满足条件的点的最大距离</td>
</tr>
<tr>
<td>corner_filter_size</td>
<td>线状特征点云体素滤波大小</td>
</tr>
<tr>
<td>surf_filter_size</td>
<td>面状特征点云体素滤波大小</td>
</tr>
<tr>
<td>map_filter_size</td>
<td>子图点云体素滤波大小</td>
</tr>
<tr>
<td>skip_count</td>
<td>使用激光里程计数据的间隔</td>
</tr>
<tr>
<td>num_max_iterations</td>
<td>进行位姿优化时的最大迭代次数，建图时设置大一些一般取10,定位为了实时性可以适当取小一些，一般取1</td>
</tr>
<tr>
<td>delta_r_abort</td>
<td>进行位姿优化时，旋转矩阵变化值太小时则提前终止</td>
</tr>
<tr>
<td>delta_t_abort</td>
<td>进行位姿优化时，平移向量变化值太小时则提  前终止</td>
</tr>
<tr>
<td>mapping_method</td>
<td>进行位姿优化时，帧到局部子图进行匹配还是到全局地图</td>
</tr>
<tr>
<td>window_size</td>
<td>滑窗大小，一般室内取12,室外取7               <strong><em>         （改成室内模式、室外模式）</em></strong></td>
</tr>
<tr>
<td>opt_window_size</td>
<td>滑窗中进行位姿优化的窗口大小，一般室内取7,室外取5              <strong><em>         （改成室内模式、室外模式）</em></strong></td>
</tr>
<tr>
<td>init_window_factor</td>
<td>是否初始化窗口（1）</td>
</tr>
<tr>
<td>estimate_extrinsic</td>
<td>是否估计外参（0）</td>
</tr>
<tr>
<td>opt_extrinsic</td>
<td>是否优化外参（0）</td>
</tr>
<tr>
<td>acc_n</td>
<td>加速度计噪声</td>
</tr>
<tr>
<td>gyr_n</td>
<td>陀螺仪噪声</td>
</tr>
<tr>
<td>acc_w</td>
<td>加速度计偏置</td>
</tr>
<tr>
<td>gyr_w</td>
<td>陀螺仪偏置</td>
</tr>
<tr>
<td>g_norm</td>
<td>重力加速度</td>
</tr>
<tr>
<td>run_optimization</td>
<td>是否采用优化（1）</td>
</tr>
<tr>
<td>update_laser_imu</td>
<td>是否优化后对激光做运动改正（1）</td>
</tr>
<tr>
<td>imu_factor</td>
<td>IMU是否参与优化（1）</td>
</tr>
<tr>
<td>point_distance_factor</td>
<td>激光是否参与优化（1）</td>
</tr>
<tr>
<td>prior_factor</td>
<td>是否添加先验（0）</td>
</tr>
<tr>
<td>marginalization_factor</td>
<td>是否添加边缘化（0）</td>
</tr>
<tr>
<td>odom_io</td>
<td>局部轨迹偏移量（3）</td>
</tr>
<tr>
<td>enable_deskew</td>
<td>是否优化前对激光做改正（1）</td>
</tr>
<tr>
<td>cutoff_deskew</td>
<td>是否优化前对激光做运动改正（0）</td>
</tr>
<tr>
<td>keep_features</td>
<td>是否保持特征点（0）</td>
</tr>
<tr>
<td>msg_time_delay</td>
<td>时间延迟（0.0）</td>
</tr>
<tr>
<td>opti_max_max_num_iterations</td>
<td>紧耦合优化最大次数（10）</td>
</tr>
<tr>
<td>opti_num_threads</td>
<td>紧耦合优化最大线程数（8）</td>
</tr>
<tr>
<td>keep_feature_size</td>
<td>是否限定特征点数量（1）</td>
</tr>
<tr>
<td>max_feature_size</td>
<td>限定特征点的最大数量值（1500）</td>
</tr>
<tr>
<td>fdcp.top_seed_size</td>
<td>全局配准时使用的最大种子点数量</td>
</tr>
<tr>
<td>loop_closure.loop_matching.fdcp.score</td>
<td>全局配准分数阈值，取值[0,1]</td>
</tr>
<tr>
<td>loop_closure.loop_matching.m2_score</td>
<td>点到面ICP配准分数阈值，取值[0,1]</td>
</tr>
<tr>
<td>loop_closure.switch_information_matrix</td>
<td>位姿图优化开关量信息矩阵</td>
</tr>
<tr>
<td>loop_closure.loop_matching_step</td>
<td>闭环检测步长</td>
</tr>
<tr>
<td>localization.submap_num</td>
<td>定位时构成局部子图的帧数</td>
</tr>
<tr>
<td>localization.global_submap_distance</td>
<td>定位时搜索全局顶点的半径</td>
</tr>
<tr>
<td>localization.global_step</td>
<td>定位时生成候选位置点间隔</td>
</tr>
<tr>
<td>localization.score1</td>
<td>定位配准分数1阈值，取值[0,1]</td>
</tr>
<tr>
<td>localization.score2</td>
<td>定位配准分数2阈值，取值[0,1],一般比分数1要大</td>
</tr>
<tr>
<td>robot_height</td>
<td>机器人高度，要求建图和定位使用的是同一台机器</td>
</tr>
<tr>
<td>map_merge.global_loop_matching_step</td>
<td>增量建图，全局地图闭环检测步长</td>
</tr>
<tr>
<td>map_merge.score</td>
<td>增量建图分数阈值，取值[0,1]</td>
</tr>
</tbody>
</table>
<h2 id="_5">使用例程</h2>
<h3 id="_6">自带例子说明</h3>
<p>在examples目录下,有若干个文件用于测试,以mapping为例,步骤如下:</p>
<ol>
<li>cd mapping</li>
<li>mkdir build</li>
<li>cd build</li>
<li>cmake ..</li>
<li>make </li>
<li>./lins_mapping_ros_node</li>
</ol>
<table>
<thead>
<tr>
<th>文件名</th>
<th>作用</th>
<th>依赖</th>
<th>生成可执行文件</th>
</tr>
</thead>
<tbody>
<tr>
<td>lins_mapping_ros</td>
<td>建图</td>
<td>ros</td>
<td>lins_mapping_ros_node</td>
</tr>
<tr>
<td>lins_auto_init_localization_ros</td>
<td>自动定位</td>
<td>ros</td>
<td>lins_auto_init_localization_ros_node</td>
</tr>
<tr>
<td>mapping_auto_merge</td>
<td>建图</td>
<td>ros</td>
<td>lins_mapping_merge_ros_node</td>
</tr>
<tr>
<td>lins_localization_ros</td>
<td>手动定位</td>
<td>ros</td>
<td>lins_localization_ros_node</td>
</tr>
</tbody>
</table>
<h3 id="_7">例程文件简览</h3>
<pre><code class="language-c++">#include &quot;lins_mapping_ros.h&quot;
#include &lt;pcl/common/transforms.h&gt;


LINSMappingRos::LINSMappingRos(ros::NodeHandle nh, std::string config_filename) :
        nh_(nh),
        config_file_(config_filename),
        fusion_mapping_ptr_(new lins::FusionMappingMth(config_filename)){

    config_.set_config_filename(config_file_);
    laser_sub_ = nh_.subscribe(config_.lidar_topic, 10, &amp;LINSMappingRos::LaserCallback, this);
    imu_sub_ = nh_.subscribe(config_.imu_topic, 200, &amp;LINSMappingRos::ImuCallback, this);

    output_thd = std::thread(std::bind(&amp;LINSMappingRos::Output, this));
    render_timer_.StartTimer(10, std::bind(&amp;LINSMappingRos::RenderUpdate, this));

    std::cout &lt;&lt; &quot; init done&quot; &lt;&lt; std::endl;
}

LINSMappingRos::~LINSMappingRos() {
}

void LINSMappingRos::LaserCallback(const sensor_msgs::PointCloud2::ConstPtr &amp;msg) {
    pcl::PointCloud&lt;pcl::PointXYZI&gt; raw_cloud_pcl;
    pcl::fromROSMsg(*msg, raw_cloud_pcl);

    /// laser frame to body frame
    pcl::PointCloud&lt;pcl::PointXYZI&gt; point_cloud_pcl;
    pcl::transformPointCloud(raw_cloud_pcl, point_cloud_pcl, config_.TBL, Eigen::Quaterniond(config_.RBL));

    lins::PointCloud point_cloud;
    test::copyPointCloud(point_cloud_pcl, point_cloud);

    double timestamp = msg-&gt;header.stamp.toSec();
    lins::LaserReading laser_reading;
    laser_reading.timestamp = timestamp;
    laser_reading.pointcloud = point_cloud;

    std::cout&lt;&lt;__LINE__&lt;&lt;std::endl;
    fusion_mapping_ptr_-&gt;InputLaserData(laser_reading);
}

void LINSMappingRos::ImuCallback(const sensor_msgs::Imu::ConstPtr &amp;msg) {
    double t = msg-&gt;header.stamp.toSec();
    double dx = msg-&gt;linear_acceleration.x;
    double dy = msg-&gt;linear_acceleration.y;
    double dz = msg-&gt;linear_acceleration.z;
    double rx = msg-&gt;angular_velocity.x;
    double ry = msg-&gt;angular_velocity.y;
    double rz = msg-&gt;angular_velocity.z;
    Eigen::Vector3d acc(dx, dy, dz);
    Eigen::Vector3d gyr(rx, ry, rz);

    lins::IMUReading imu_reading;
    imu_reading.timestamp = t;
    imu_reading.linear_acceleration = acc;
    imu_reading.angular_velocity = gyr;

    std::cout&lt;&lt;__LINE__&lt;&lt;std::endl;
    fusion_mapping_ptr_-&gt;InputRawImuData(imu_reading);
}

void LINSMappingRos::Output() {
    while (true) {
        char key = std::getchar();
        if (key == 'm') {
            fusion_mapping_ptr_-&gt;OutputHMap(&quot;/home/zhihui/workspace/DATA/LaserLoopMapping/location/test/map.hmap&quot;,
                                            &quot;/home/zhihui/workspace/DATA/LaserLoopMapping/location/test/map.png&quot;,
                                            &quot;/home/zhihui/workspace/DATA/LaserLoopMapping/location/test/map.yaml&quot;,lins::ColorMode::WHITE_BLACK);
            std::cout &lt;&lt; &quot;output hmap done&quot; &lt;&lt; std::endl;
        } else if (key == 'r')
        {
            std::cout &lt;&lt; &quot;mapping reset start&quot; &lt;&lt; std::endl;

            fusion_mapping_ptr_ = std::make_shared&lt;lins::FusionMappingMth&gt;(config_file_);
            render::MappingVisualRender::getInstance().Clear();

            std::cout &lt;&lt; &quot;mapping reset done&quot; &lt;&lt; std::endl;
        }
    }
}

void LINSMappingRos::RenderUpdate() {
    /// lio trajectory
    Eigen::Quaterniond lio_q = fusion_mapping_ptr_-&gt;get_lio_pose().unit_quaternion().cast&lt;double&gt;();
    Eigen::Vector3d lio_p = fusion_mapping_ptr_-&gt;get_lio_pose().translation().cast&lt;double&gt;();
    render::MappingVisualRender::getInstance().InputLIOLaserPose(lio_q, lio_p);
    render::MappingVisualRender::getInstance().InputLIOLaserTraj(lio_q, lio_p);

    /// mapp trajectory
    Eigen::Quaterniond mapp_q = fusion_mapping_ptr_-&gt;get_current_pose().unit_quaternion().cast&lt;double&gt;();
    Eigen::Vector3d mapp_p = fusion_mapping_ptr_-&gt;get_current_pose().translation().cast&lt;double&gt;();
    render::MappingVisualRender::getInstance().InputMappPose(mapp_q, mapp_p);
    render::MappingVisualRender::getInstance().InputMappTraj(fusion_mapping_ptr_-&gt;get_current_scan_id(), mapp_q, mapp_p);

    std::vector&lt;Eigen::Vector3d&gt; cloud;
    for (auto p : fusion_mapping_ptr_-&gt;get_current_surf_scan()) {
        cloud.push_back(Eigen::Vector3d(p.x, p.y, p.z));
    }
    std::vector&lt;Eigen::Vector3d&gt; submapCloud;
    for (auto p : fusion_mapping_ptr_-&gt;get_current_submap_scan()) {
        submapCloud.push_back(Eigen::Vector3d(p.x, p.y, p.z));
    }
    std::vector&lt;Eigen::Vector3d&gt; scan_cloud;
    for (auto p : fusion_mapping_ptr_-&gt;get_current_full_scan()) {
        scan_cloud.push_back(Eigen::Vector3d(p.x, p.y, p.z));
    }

    render::MappingVisualRender::getInstance().InputSubmapCloud(submapCloud);
    render::MappingVisualRender::getInstance().InputMappScan(scan_cloud);

    static int render_count = 0;
    if (render_count % 20 == 0) {
        render::MappingVisualRender::getInstance().InputMappCloud(fusion_mapping_ptr_-&gt;get_current_scan_id(), cloud);
    }
    render_count++;

    auto backend_data = fusion_mapping_ptr_-&gt;get_global_data();
    std::vector&lt;Eigen::Vector3d&gt; backend_traj;
    for (auto p : std::get&lt;0&gt;(backend_data)) {
        backend_traj.push_back(p.translation());
    }
    std::vector&lt;std::pair&lt;Eigen::Vector3d, Eigen::Vector3d&gt;&gt; match_edges;
    for (auto p : std::get&lt;1&gt;(backend_data)) {
        match_edges.push_back(std::pair&lt;Eigen::Vector3d, Eigen::Vector3d&gt;(p.first.translation(), p.second.translation()));
    }
    std::vector&lt;Eigen::Vector3d&gt; global_cloud;
    for (auto p : std::get&lt;2&gt;(backend_data)) {
        global_cloud.push_back(Eigen::Vector3d(p.x, p.y, p.z));
    }
    render::MappingVisualRender::getInstance().InputVertex(backend_traj);
    render::MappingVisualRender::getInstance().InputEdge(match_edges);
    render::MappingVisualRender::getInstance().InputLaserCloud(global_cloud);
}

</code></pre>
<p>main函数</p>
<pre><code>#include &quot;lins_mapping_ros.h&quot;
#include &lt;glog/logging.h&gt;
#include &lt;sensor_msgs/PointCloud2.h&gt;
#include &lt;sensor_msgs/Imu.h&gt;

int main(int argc, char **argv) {

    google::InstallFailureSignalHandler();      //捕捉 core dumped
    google::InstallFailureWriter([](const char* data,int size){
        std::string str=std::string(data,size);
        LOG(ERROR)&lt;&lt;str;
    });
    std::cout&lt;&lt;&quot;argc&quot;&lt;&lt;argc&lt;&lt;std::endl;
    std::cout&lt;&lt;&quot;argv[0]&quot;&lt;&lt;argv[0]&lt;&lt;std::endl;
    std::cout&lt;&lt;&quot;argv[1]&quot;&lt;&lt;argv[1]&lt;&lt;std::endl;
    ros::init(argc, argv, &quot;lins_mapping_ros&quot;);
    ros::NodeHandle nodeHandle;

    FLAGS_colorlogtostderr = true;

    std::string config_path = argv[1];
    LINSMappingRos::Ptr lins_mapping_ptr(new LINSMappingRos(nodeHandle, config_path));

    ros::spin();

    return 1;
}
</code></pre>
<h3 id="_8">从零开始构建项目</h3>
<ul>
<li>首先我们需要创建一个新的文件夹做工作目录,我们假设为<code>test</code></li>
<li>cd <code>test</code></li>
<li>在<code>test</code>目录下解压 <code>LinsMappingSDK.rar</code></li>
<li>
<p>cd <code>lins_sdk</code>  看到到 <code>lins_sdk</code>文件夹内部有</p>
<ul>
<li><code>/include</code> SDK的头文件</li>
<li><code>/lib</code> SDK的静态库本身与其cmakeconfig文件</li>
<li><code>/config</code> 项目参数,本身提供了默认的参数数值,也可以根据您的项目需要修改</li>
</ul>
</li>
<li>
<p><code>cd ..</code> &amp;&amp;<code>mkdir src include build</code> 分别存放即将编写的头文件,源文件,编译生成文件</p>
</li>
<li><code>cd ./src</code> </li>
<li>`vim test.cpp 编写源文件</li>
</ul>
<pre><code class="language-c++">                #include &lt;lins/mapping/fusion_mapping_mtd.h&gt;
                #include &lt;lins/mapping/fusion_mapping_merge_mtd.h&gt;
                #include &lt;lins/localization/fusion_localization_manual_init_mtd.h&gt;
                #include &lt;lins/localization/fusion_localization_auto_init_mtd.h&gt;

                  #include &lt;lins/core/common/config.h&gt;
                  int main(int argc , char **argb)
                  {
                          std::cout&lt;&lt;&quot;=====================================fusion_mapping===============================&quot;&lt;&lt;std::endl;
                          lins::FusionMappingMth fusion_mapping(&quot;/home/zhihui/workspace/test/lins_sdk/config/config_auto_init_fusion_localization.yaml&quot;);
                          std::cout&lt;&lt;&quot;=====================================fusion_mapping_merge===============================&quot;&lt;&lt;std::endl;
                          lins::FusionMappingMergeMth fusion_mapping_merge(&quot;/home/zhihui/workspace/test/lins_sdk/config/config_auto_init_fusion_localization.yaml&quot;);
                          std::cout&lt;&lt;&quot;=====================================fusion_localization_Manual===============================&quot;&lt;&lt;std::endl;
                          lins::FusionLocalizationManualInitMtd fusion_localization_Manual(&quot;/home/zhihui/workspace/test/lins_sdk/config/config_auto_init_fusion_localization.yaml&quot;);
                          std::cout&lt;&lt;&quot;=====================================fusion_localization_auto===============================&quot;&lt;&lt;std::endl;
                          lins::FusionLocalizationAutoInitMtd fusion_localization_auto(&quot;/home/zhihui/workspace/test/lins_sdk/config/config_auto_init_fusion_localization.yaml&quot;);
                  }

</code></pre>
<ul>
<li>cd ../test 回到工作目录</li>
<li>vim CMakelist.txt 编写链接库文件的CMakelist</li>
</ul>
<pre><code class="language-cmake">                                    cmake_minimum_required(VERSION 2.8)
                                    project(test)

                                    set(CMAKE_BUILD_TYPE &quot;Release&quot;)
                                    set(CMAKE_CXX_STANDARD 14)

                                    # 我们假设您的库路径为 ${SDK_DIR} 具体路径需要自己给出
                                    set(CMAKE_PREFIX_PATH &quot;${SDK_DIR}/lib/cmake;${CMAKE_PREFIX_PATH}&quot;)

                                    find_package(lins REQUIRED)

                                    include_directories(
                                    ${lins_INCLUDE_DIRS}
                                    )


                                    add_executable(test
                                    src/test.cpp
                                    )

                                    target_link_libraries(test
                                    ${lins_LIBRARIES}           ### must before ${catkin_LIBRARIES}, may cause runtime error
                                    )
</code></pre>
<ul>
<li>cd build &amp;&amp; cmake .. &amp;&amp; make</li>
<li>./test 正常运行四种封装好的功能模块,后续可以根据自己的需求编写代码</li>
</ul>
              
            </div>
          </div>
          <footer>
  
    <div class="rst-footer-buttons" role="navigation" aria-label="footer navigation">
      
        <a href="about/index.html" class="btn btn-neutral float-right" title="接口介绍">Next <span class="icon icon-circle-arrow-right"></span></a>
      
      
    </div>
  

  <hr/>

  <div role="contentinfo">
    <!-- Copyright etc -->
    
  </div>

  Built with <a href="https://www.mkdocs.org/">MkDocs</a> using a <a href="https://github.com/snide/sphinx_rtd_theme">theme</a> provided by <a href="https://readthedocs.org">Read the Docs</a>.
</footer>
      
        </div>
      </div>

    </section>

  </div>

  <div class="rst-versions" role="note" aria-label="versions">
    <span class="rst-current-version" data-toggle="rst-current-version">
      
      
      
        <span style="margin-left: 15px"><a href="about/index.html" style="color: #fcfcfc">Next &raquo;</a></span>
      
    </span>
</div>
    <script>var base_url = '.';</script>
    <script src="js/theme.js" defer></script>
      <script src="search/main.js" defer></script>
    <script defer>
        window.onload = function () {
            SphinxRtdTheme.Navigation.enable(true);
        };
    </script>

</body>
</html>

<!--
MkDocs version : 1.2.dev1
Build Date UTC : 2020-12-17 03:54:47.744415+00:00
-->
